// // 冒泡排序
// export const deweigth = (arr) => {
//     for (let i = 0; i < arr.length - 1; i++) {//循环3次
//         for (let j = 0; j < arr.length - 1 - i; j++) {//第一圈循环三次把最大值放到最后
//             if (arr[j] > arr[j + 1]) {//两两比较，最大值放到最后
//                 var temp = arr[j];
//                 arr[j] = arr[j + 1];
//                 arr[j + 1] = temp;
//             }
//         }
//     }
//     return arr
// }
// 冒泡去重
export const weight=(arrremove)=>{
    for (let i = 0; i < arrremove.length-1; i++) {
        for (let j = i+1; j < arrremove.length; j++) {
            if (arrremove[i] == arrremove[j]) {
                arrremove.splice(j, 1);
                j--;  //因为数组长度减小1，所以直接 j++ 会漏掉一个元素，所以要 j--
            } 
        }
    }
    return arrremove
}



// 防抖
export function _debounce(fn, delay) {
 
    var delay = delay || 200;
    var timer;
    return function () {
        var th = this;
        var args = arguments;
        if (timer) {
            clearTimeout(timer);
        }
        timer = setTimeout(function () {
            timer = null;
            fn.apply(th, args);
        }, delay);
    };
}
// 节流
export function _throttle(fn, interval) {
    var last;
    var timer;
    var interval = interval || 200;
    return function () {
        var th = this;
        var args = arguments;
        var now = +new Date();
        if (last && now - last < interval) {
            clearTimeout(timer);
            timer = setTimeout(function () {
                last = now;
                fn.apply(th, args);
            }, interval);
        } else {
            last = now;
            fn.apply(th, args);
        }
    }
}